package com.blue.fish.tiny.parser.ast;

import com.blue.fish.tiny.parser.util.PeekTokenIterator;
import com.blue.fish.tiny.lexer.Token;
import com.blue.fish.tiny.lexer.TokenType;

/**
 * @author QingFan
 * @version 1.0.0
 * @date 2023年01月30日 21:34
 */
public abstract class Factor extends ASTNode {

    public Factor(ASTNode parent, PeekTokenIterator it) {
        super(parent);
        Token token = it.next();
        TokenType type = token.getType();

        if (type == TokenType.VARIABLE) {
            this.type = ASTNodeTypes.VARIABLE;
        } else {
            this.type = ASTNodeTypes.SCALAR;
        }
        this.label = token.getValue();
        this.lexeme = token;
    }
}
